package org.gourpg.entity.dictionary;


import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Objects;

/**
 * 字典工程配置实体
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "noun_class_detail")
public class NounClassDetail {
    /**
     * 字典工程ID，字典工程的主键
     */
    @Id
    private Long nounClassId;
    /**
     * 字典工程对象类全路径
     */
    private String nounClassPath;
    /**
     * 字典工程对应的数据表
     */
    private String nounTableName;
    /**
     * 获取id text parentid的数据库脚本
     */
    private String nounGetSql;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        NounClassDetail that = (NounClassDetail) o;
        return getNounClassId() != null && Objects.equals(getNounClassId(), that.getNounClassId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
